package com.nami.store.dubbo;

import com.nami.store.api.request.conversation.ConverAddReq;
import com.nami.store.api.request.conversation.ConverC2CUpdRequest;
import com.nami.store.api.request.conversation.ConverItem;
import com.nami.store.api.request.conversation.ConverPageReq;
import com.nami.store.api.service.RemoteConverService;
import com.nami.store.api.response.conversation.ConversationDTO;
import com.nami.store.api.response.conversation.ConverDetailVO;
import com.nami.store.biz.cache.application.CacheAppService;
import com.nami.store.biz.conver.application.ConverAppService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.DubboService;
import org.dromara.common.mybatis.core.page.TableDataInfo;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 描述：
 *
 * @Author: lbc
 * @Date: 2023-07-24 15:50
 * @email: 594599620@qq.com
 * @Description: keep coding
 */
@Slf4j
@DubboService
@Service
@RequiredArgsConstructor
public class RemoteConverServiceImpl implements RemoteConverService {

    private final ConverAppService converAppService;
    private final CacheAppService cacheAppService;

    @Override
    public ConversationDTO getConverFromCacheOrDB(String appKey, String userId, String targetId) {
        return converAppService.getConverFromCacheOrDB(appKey, userId, targetId);
    }

    @Override
    public ConverItem getConverFromCache(String appKey, String userId, String targetId) {
        return converAppService.getConverFromCache(appKey, userId, targetId);
    }

    @Override
    public boolean updPrivateChatConvers(ConverC2CUpdRequest request) {
        return converAppService.updPrivateChatConver(request);
    }

    @Override
    public boolean updConvers(List<ConverItem> itemList) {
        return converAppService.batchUpdConvers(itemList);
    }

    @Override
    public List<ConversationDTO> getConversFromCacheOrDb(String appKey, List<String> userIds, String targetId) {
        return converAppService.getConversFromCacheOrDb(appKey, userIds, targetId);
    }

    @Override
    public boolean batchSave(List<ConverAddReq> requests) {
        return converAppService.batchSave(requests);
    }

    @Override
    public boolean insertOrUpd(ConverItem item) {
        return converAppService.insertOrUpd(item);
    }

    @Override
    public boolean writeCache(ConverItem converItem) {
        return cacheAppService.writeConverItem(converItem);
    }

    @Override
    public TableDataInfo<ConverDetailVO> getConverFromPage(ConverPageReq request) {
        return converAppService.getConvers(request);
    }

}
